<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ page import="kr.co.insoft.framework.config.Authorities"%>
<c:set var="CONTEXT">${pageContext.request.contextPath}</c:set>
<c:set var="cssUrl">${pageContext.request.contextPath}/resources/css</c:set>
<c:set var="jsUrl">${pageContext.request.contextPath}/resources/js</c:set>
<spring:message code="button.search.text" var="searchText"/>
<div class="col-sm-12 page-header custom-page-header">
	<h1><spring:message code="menu.configration.cloudconnection"/></h1>	
</div>
<form:form modelAttribute="pagingModel" role="form" cssClass="col-sm-12">
	<input id="currentPage" name="currentPage" type="hidden" value="${pagingModel.currentPage}" />
	<input id="venderid" name="venderid" type="hidden" value="${vender.venderid}" />
	<div class="form-group">
		<h3>Vender Information of Connections</h3>
		<div class="col-sm-1"> 
			<label><spring:message code="configration.cloud.vender"/></label> 
		</div>
		<div class="col-sm-3">
			<select id="venderList" class="form-control">
                <c:forEach items="${venderComboList }" var="venderItem">
                <c:choose>
                    <c:when test="${(not empty vender.venderid) and (vender.venderid eq venderItem.venderid)}"><option selected="selected" value="${venderItem.venderid }">${venderItem.venderName }</option></c:when>
                    <c:otherwise><option value="${venderItem.venderid }">${venderItem.venderName }</option></c:otherwise>
                </c:choose>
                </c:forEach>
            </select>
		</div>				
	</div>
	 
	<div class="form-group">
		<table class="table table-hover">
			<colgroup>
				<col width="250px"/>
				<col width="*"/>
			</colgroup>			
			<tbody>
				<tr>
					<th><spring:message code="configration.cloud.venderName"/></th>
					<td>${vender.venderName }</td>
				</tr>
				<tr>
					<th><spring:message code="configration.cloud.venderType"/></th> 
					<td>${vender.typeName}</td>
				</tr>
				<tr>
					<th><spring:message code="configration.cloud.venderDesc"/></th>
					<td>${vender.venderDesc }</td>
				</tr>
			</tbody>
		</table>
	</div>
	 
	<div class="row"></div>
	<h3>Connection List</h3> 
	<div class="col-sm-12 form-group">
		<div class="col-sm-offset-7 col-sm-3">
			<div class="input-group">
				<input type="text" placeholder="${searchText }" name="searchAndCondition['connectionName']" class="form-control" value="${pagingModel.searchAndCondition['connectionName']}" />
				<span class="input-group-btn">
					<button class="btn btn-primary"><spring:message code="button.search"/></button> 
				</span>
			</div>
		</div>
		<div class="col-sm-2">
		<form:select path="viewRow" cssClass="form-control">
			<form:option value="10">10 개</form:option>
			<form:option value="25">25 개</form:option>
			<form:option value="50">50 개</form:option>
			<form:option value="100">100 개</form:option>
		</form:select>
		</div>
	</div>
		
	<div class="form-group">				
		<table class="table table-hover">
			<thead>
				<tr>
					<th><spring:message code="configration.cloud.connectionName"/></th>
					<th><spring:message code="configration.cloud.regionName"/></th>
					<th><spring:message code="configration.cloud.zoneName"/></th>					
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${empty pagingModel.lists }">
						<tr class="warning">
							<td colspan="4"><spring:message code="list.no.result"/></td>
						</tr>
					</c:when>
					<c:otherwise>
						<c:forEach items="${pagingModel.lists }" var="item">
							<tr>
								<td><a href="#" class="btn_link"  data-link="./view?connectionid=${item.connectionid }">${item.connectionName }</a></td>
								<td>${item.regionName }</td> 
								<td>${item.zoneName }</td>
							</tr>
						</c:forEach>
					</c:otherwise>
				</c:choose>
			</tbody>
		</table>
	</div>

	<div class="form-group text-center">
		<c:if test="${not empty pagingModel.lists }">
			<ul class="pagination">
				<li><a href="#" class="pages" data-page="${pagingModel.paging.previousBlock }">&laquo;</a></li>
				<c:forEach items="${pagingModel.paging.pages }" var="pages">
					<c:choose>
						<c:when test="${pages eq pagingModel.paging.currentPageNum }">
							<li class="active"><a href="#" class="pages" data-page="${pages }">${pages }</a></li>
						</c:when>
						<c:otherwise>
							<li><a href="#" class="pages" data-page="${pages }">${pages }</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				<li><a href="#" class="pages" data-page="${pagingModel.paging.nextBlock}">&raquo;</a></li>
			</ul>
		</c:if>
	</div>
	<div class="text-right">
		<c:if test="${fn:contains(buttons , Authorities.CREATE)}">
			<button type="button" class="btn btn-primary btn_link"
				data-link="./createForm"><spring:message code="button.create"/></button>
		</c:if>
	</div>
</form:form>



<script type="text/javascript">
<!--
	$(document).ready(function() {
		$("#venderList").on("change", function(){
			$("#venderid").val($(this).val());
			$("#pagingModel").submit();
		});
	});	
//-->
</script>